package exam.web.action.base;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;

import exam.common.util.ConvertUtils;
import exam.model.entity.TQuestionEntity;
import exam.system.business.BusinessServiceInfo;

/**
 * <p>QuestionActionBase</p>
 * 
 * @author Phong
 * @version (create 02/05/2012) (update 21/5/2012)
 */

public class QuestionActionBase extends ActionSupport 
		implements ServletRequestAware, ServletResponseAware {
	/**
	 * serialVersionUID
	 */
	protected static final long serialVersionUID = 1L;
	
	// serviceInfo
	protected BusinessServiceInfo serviceInfo = new BusinessServiceInfo();
	
	// request
	protected HttpServletRequest request;
	
	// response
	protected HttpServletResponse response;

	// QUESTION_ID
	protected long questionId;
	// QUESTION_CONTENT
	protected String questionContent;
	// QUESTION_TYPE
	protected boolean questionType;
	// QUESTION_MARK
	protected int questionMark;
	// CORRECT_NUM
	protected int correctNum;
	// SUB_QUEST_ID
	protected long subQuestId;
	// USER_ID
	protected long userId;	
	// CREATE_DATE
	protected Date createDate;
	// UPDATE_DATE
	protected Date updateDate;
	
	// Set/Get questionId
	public long getQuestionId() {
		return questionId;
	}
	public void setQuestionId(long questionId) {
		this.questionId = questionId;
	}
	
	// Set/Get questionContent
	public String getQuestionContent() {
		return questionContent;
	}
	public void setQuestionContent(String questionContent) {
		this.questionContent = questionContent;
	}
	
	// Set/Get questionType
	public boolean isQuestionType() {
		return questionType;
	}
	public void setQuestionType(boolean questionType) {
		this.questionType = questionType;
	}
	
	// Set/Get questionMark
	public int getQuestionMark() {
		return questionMark;
	}
	public void setQuestionMark(int questionMark) {
		this.questionMark = questionMark;
	}
	
	// Set/Get correctNum
	public int getCorrectNum() {
		return correctNum;
	}
	public void setCorrectNum(int correctNum) {
		this.correctNum = correctNum;
	}
	
	// Set/Get subQuestId
	public long getSubQuestId() {
		return subQuestId;
	}
	public void setSubQuestId(long subQuestId) {
		this.subQuestId = subQuestId;
	}
	
	// Set/Get userId
	public long getUserId() {
		return userId;
	}
	public void setUserId(long userId) {
		this.userId = userId;
	}
	
	// Set/Get createDate
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	// Set/Get updateDate
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	
	// Cac phuong thuc override
	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	/**
	 * copyToTQuestionEntity
	 * @param tQuestionEntity
	 */
	public void copyToTQuestionEntity(TQuestionEntity tQuestionEntity) {
		tQuestionEntity.setQuestionId(questionId);
		tQuestionEntity.setQuestionContent(questionContent);
		tQuestionEntity.setQuestionType(ConvertUtils.convertBooleanToInt(questionType));
		tQuestionEntity.setQuestionMark(questionMark);
		tQuestionEntity.setCorrectNum(correctNum);
		tQuestionEntity.setSubQuestId(subQuestId);
		tQuestionEntity.setUserId(userId);
	}
	
	/**
	 * copyFromTQuestionEntity
	 * @param tQuestionEntity
	 */
	public void copyFromTQuestionEntity(TQuestionEntity tQuestionEntity) {
		questionId = tQuestionEntity.getQuestionId();
		questionContent = tQuestionEntity.getQuestionContent();
		questionType = ConvertUtils.convertIntToBoolean(tQuestionEntity.getQuestionType());
		questionMark = tQuestionEntity.getQuestionMark();
		correctNum = tQuestionEntity.getCorrectNum();
		subQuestId = tQuestionEntity.getSubQuestId();
		userId = tQuestionEntity.getUserId();
		createDate = tQuestionEntity.getCreateDate();
		updateDate = tQuestionEntity.getUpdateDate();
	}
	
}
